import {actionTypes} from '.';
import {fromJS} from "immutable";
import axios from "axios";

export const getChangePage=(page)=>({
    type:actionTypes.CHANGE_PAGE,
    page
})


export const getMouseLeave=()=>({
    type:actionTypes.MOUSE_LEAVE,
})


export const getMouseEnter=()=>({
    type:actionTypes.MOUSE_ENTER,
})


export function getList() {
    return (dispatch) => {
        axios.get('http://localhost:3000/headList').then(res => {
            const data = res.data;
            dispatch(changeList(data.data));
        }).catch((err) => {
            alert(err)
        })
    };
}

const changeList = (data) => ({
    type: actionTypes.CHANGE_LIST,
    data: fromJS(data),//将数据编程immutable类型
    totalPage: Math.ceil(data.length / 10)
})

export const getInputFocus = () => ({
    type: actionTypes.INPUT_FOCUS
})
export const getInputBlur = () => ({
    type: actionTypes.INPUT_BLUR
})